<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2020/4/1
  Time: 10:27
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" language="java" %>
<%
    pageContext.setAttribute("path", request.getContextPath());
%>
<html>
<head>
    <style>

        div.search {padding: 30px 0;}

        input, button {
            border: none;
            outline: none;
        }
        input {

        }


        /*搜索框1*/
        .bar1 input {
            border: 2px solid #7BA7AB;
            border-radius: 5px;
            background: #F9F0DA;
            color: #9E9C9C;
        }
        .bar1 button {
            top: 0;
            right: 0;
            background: #7BA7AB;
            border-radius: 0 5px 5px 0;
        }
        .bar1 button:before {
            content: "\f002";
            font-family: FontAwesome;
            font-size: 16px;
            color: #F9F0DA;
        }


    </style>
    <title>Worker列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="http://cdn.bootcss.com/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"/>
    <link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

    <script language="javascript">

        function Check() {
            if (document.getElementById("text").value == "") {
                alert("搜索内容不能为空");
                return false;
            }
            else {

            }
        }

        $(document).ready(function(){


            if(${paixu_query_type == "paixuSelectById"}) {
                $("#paixu_query_type option[value='paixuSelectById']").prop("selected","selected");
            }else if (${paixu_query_type == "paixuSelectByName"}){
                $("#paixu_query_type option[value='paixuSelectByName']").prop("selected","selected");
            }else if (${paixu_query_type == "paixuSelectByWorkage"}){
                $("#paixu_query_type option[value='paixuSelectByWorkage']").prop("selected","selected");
            }
        });

        function del(id) {
            if (confirm("确认要删除？")) {
                window.location.href="${path}/worker/del/"+id;
            }
        }

        function shengxu(){
            sessionStorage.clear();
            sessionStorage.setItem("paixu","0");
        }

        function jiangxu(){
            sessionStorage.clear();
            sessionStorage.setItem("paixu","1");
        }

    </script>
</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    基于SSM框架的管理系统：简单实现增、删、改、查。
                </h1>
            </div>
        </div>
    </div>

    <div class="search bar1">
        <form action="/worker/queryResult" style=" position: relative;
            width: 400px;
            margin: 0 auto; ">
            <input name="text" id="text" type="text" placeholder="请输入您要搜索的内容..." style="width: 100%;
            height: 42px;
            padding-left: 13px;">
            <select name="query_type" style="position: absolute;height: 42px;border-radius: 5px;margin-left: 10px;">
                <option value="selectById" name="idQuery">按id</option>
                <option value="selectByName" name="nameQuery">按姓名</option>
            </select>
            <button type="submit" style=" height: 42px;
            width: 42px;
            cursor: pointer;
            position: absolute;" onclick="return Check()"></button>
        </form>
    </div>



    <%--<div class="query">--%>
    <%--<form action="/worker/queryResult">--%>
    <%--<input name="text"/>--%>
    <%--<select name="query_type">--%>
    <%--<option value="selectById" name="idQuery">按id</option>--%>
    <%--<option value="selectByName" name="nameQuery">按姓名</option>--%>
    <%--</select>--%>
    <%--<input type="submit" value="查询">--%>
    <%--</form>--%>
    <%--</div>--%>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    <small>员工列表</small>
                </h1>
            </div>
        </div>
    </div>
    <div class="row">
        <%--<div class="col-md-4 column" style="margin-top: 10px">--%>
            <%--<a class="btn btn-primary" href="${path}/worker/toAddWorker">新增</a>--%>
        <%--</div>--%>

        <div class="query">
            <form action="/worker/allWorker">
                <input type="submit" name="up" value="up"  style=" color:rgba(255,255,255,0);
                       font-size: 14px; float:right; background: url(/static/img/2.png) ; background-repeat:no-repeat; height: 42px;width: 42px;">
                <input type="submit" name="down" value="down" style="font-size: 1px;float:right;color:rgba(255,255,255,0);background: url(/static/img/3.png) ; background-repeat:no-repeat; height: 42px;width: 42px;">
                <select name="paixu_query_type" id="paixu_query_type" style="height: 35px;border-radius: 5px;margin-left: 10px;float: right;padding: 0;margin: 0;">
                    <option value="paixuSelectById" name="paixuIdQuery">按id</option>
                    <option value="paixuSelectByName" name="paixuNameQuery">按姓名</option>
                    <option value="paixuSelectByWorkage" name="paixuWorkageQuery">按工龄</option>
                </select>

            </form>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>出生日期</th>
                    <th>籍贯</th>
                    <th>学历</th>
                    <th>地址</th>
                    <th>电话</th>
                    <th>工龄</th>
                    <th>基本工资</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="information" items="${requestScope.get('list')}" varStatus="status">
                    <tr>
                        <td>${information.id}</td>
                        <td>${information.name}</td>
                        <td>${information.sex}</td>
                        <td>${information.birthday}</td>
                        <td>${information.birthplace}</td>
                        <td>${information.education}</td>
                        <td>${information.address}</td>
                        <td>${information.tele}</td>
                        <td>${information.workage}</td>
                        <td>${information.salary}</td>
                        <%--<td>--%>
                            <%--<a href="${path}/worker/toUpdateWorker?id=${information.id}">更改</a> |--%>
                            <%--<button onclick="del(${information.id})">删除</button>--%>
                                <%--&lt;%&ndash;href="${path}/worker/del/${information.id}"&ndash;%&gt;--%>
                        <%--</td>--%>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <form name="f1" method="POST" action="/worker/allWorker?paixu_query_type=${paixu_query_type}&down=${down}&up=${up}" onSubmit="return checknum()">
                <table border="0" align="center">
                    <tr>
                        <td>第${pages}页 共${totalpages}页 <a href="/worker/allWorker?pages=1&paixu_query_type=${paixu_query_type}&down=${down}&up=${up}">首页</a></td>
                        <td><a href="/worker/allWorker?pages=${(pages<1)?pages:(pages-1)}&paixu_query_type=${paixu_query_type}&down=${down}&up=${up}"> 上一页</a></td>
                        <td><a href="/worker/allWorker?pages=${(pages>=totalpages)?totalpages:(pages+1)}&paixu_query_type=${paixu_query_type}&down=${down}&up=${up}"> 下一页</a></td>
                        <td><a href="/worker/allWorker?pages=${totalpages}&paixu_query_type=${paixu_query_type}&down=${down}&up=${up}">最后一页</a></td>
                        <td>转到第:<input type="text" name="pages" size="8" style="border:1px solid;">页<input type="submit" value="GO" name="cndok">
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
